package fr.emse.tatiana.commands;



import org.eclipse.jface.action.Action;
import org.eclipse.jface.wizard.WizardDialog;

import org.eclipse.ui.IWorkbenchWindow;

import fr.emse.tatiana.corpus.AddFileWizard;


/**
 * Action to add a trace file to the corpus that is currently selected in the navigation view
 * 
 * @author dyke
 *
 */
public class AddFileAction extends Action {

	private final IWorkbenchWindow window;
	private final String viewId;

	private static AddFileAction instance;
	
	public static AddFileAction getInstance() {
		return instance;
	}
	
	public AddFileAction(IWorkbenchWindow window, String label, String id) {
		this.window = window;
		this.viewId = id;
		setText(label);
		// The id is used to refer to the action in a menu or toolbar
		setId(ICommandIds.CMD_ADD_FILE);
		// Associate the action with a pre-defined command, to allow key bindings.
		//setActionDefinitionId(ICommandIds.CMD_ADD_FILE);
		setImageDescriptor(fr.emse.tatiana.Activator.getImageDescriptor("/icons/import_wiz.gif"));
		this.setEnabled(false);
		instance = this;
	}


	@Override
	public void run() {
//		HolidayWizard wizard = new HolidayWizard();
//
//		if ((selection instanceof IStructuredSelection) || (selection == null))
//
//		wizard.init(part.getSite().getWorkbenchWindow().getWorkbench(), 
//
//			(IStructuredSelection)selection);
//
//			
//
//		// Instantiates the wizard container with the wizard and opens it
//
//		WizardDialog dialog = new WizardDialog( part.getSite().getShell(), wizard);
//
//		dialog.create();
//
//		dialog.open();
		
		if(window != null) {	
			AddFileWizard wizard = new AddFileWizard();
			wizard.init(window.getWorkbench(), null);
			WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
			dialog.create();
			dialog.open();
		}
	}

}
